/**
 */
package org.mro.grib.model.files.secondEdition.grids.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.mro.grib.model.files.secondEdition.grids.GridDefinitionTemplate3101;
import org.mro.grib.model.files.secondEdition.grids.GridsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Grid Definition Template3101</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.grids.impl.GridDefinitionTemplate3101Impl#getShapeOfTheEarth <em>Shape Of The Earth</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.grids.impl.GridDefinitionTemplate3101Impl#getNumberOfGridUsed <em>Number Of Grid Used</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.grids.impl.GridDefinitionTemplate3101Impl#getNumberOfGridInReference <em>Number Of Grid In Reference</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.grids.impl.GridDefinitionTemplate3101Impl#getUniversallyUniqueIdentifierOffset <em>Universally Unique Identifier Offset</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GridDefinitionTemplate3101Impl extends EObjectImpl implements GridDefinitionTemplate3101 {
	/**
	 * The default value of the '{@link #getShapeOfTheEarth() <em>Shape Of The Earth</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getShapeOfTheEarth()
	 * @generated
	 * @ordered
	 */
	protected static final byte SHAPE_OF_THE_EARTH_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getShapeOfTheEarth() <em>Shape Of The Earth</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getShapeOfTheEarth()
	 * @generated
	 * @ordered
	 */
	protected byte shapeOfTheEarth = SHAPE_OF_THE_EARTH_EDEFAULT;

	/**
	 * The default value of the '{@link #getNumberOfGridUsed() <em>Number Of Grid Used</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfGridUsed()
	 * @generated
	 * @ordered
	 */
	protected static final int NUMBER_OF_GRID_USED_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getNumberOfGridUsed() <em>Number Of Grid Used</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfGridUsed()
	 * @generated
	 * @ordered
	 */
	protected int numberOfGridUsed = NUMBER_OF_GRID_USED_EDEFAULT;

	/**
	 * The default value of the '{@link #getNumberOfGridInReference() <em>Number Of Grid In Reference</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfGridInReference()
	 * @generated
	 * @ordered
	 */
	protected static final byte NUMBER_OF_GRID_IN_REFERENCE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getNumberOfGridInReference() <em>Number Of Grid In Reference</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfGridInReference()
	 * @generated
	 * @ordered
	 */
	protected byte numberOfGridInReference = NUMBER_OF_GRID_IN_REFERENCE_EDEFAULT;

	/**
	 * The default value of the '{@link #getUniversallyUniqueIdentifierOffset() <em>Universally Unique Identifier Offset</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUniversallyUniqueIdentifierOffset()
	 * @generated
	 * @ordered
	 */
	protected static final long UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET_EDEFAULT = 0L;

	/**
	 * The cached value of the '{@link #getUniversallyUniqueIdentifierOffset() <em>Universally Unique Identifier Offset</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUniversallyUniqueIdentifierOffset()
	 * @generated
	 * @ordered
	 */
	protected long universallyUniqueIdentifierOffset = UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GridDefinitionTemplate3101Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return GridsPackage.Literals.GRID_DEFINITION_TEMPLATE3101;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getShapeOfTheEarth() {
		return shapeOfTheEarth;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setShapeOfTheEarth(byte newShapeOfTheEarth) {
		byte oldShapeOfTheEarth = shapeOfTheEarth;
		shapeOfTheEarth = newShapeOfTheEarth;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GridsPackage.GRID_DEFINITION_TEMPLATE3101__SHAPE_OF_THE_EARTH, oldShapeOfTheEarth, shapeOfTheEarth));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getNumberOfGridUsed() {
		return numberOfGridUsed;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfGridUsed(int newNumberOfGridUsed) {
		int oldNumberOfGridUsed = numberOfGridUsed;
		numberOfGridUsed = newNumberOfGridUsed;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_USED, oldNumberOfGridUsed, numberOfGridUsed));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getNumberOfGridInReference() {
		return numberOfGridInReference;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfGridInReference(byte newNumberOfGridInReference) {
		byte oldNumberOfGridInReference = numberOfGridInReference;
		numberOfGridInReference = newNumberOfGridInReference;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_IN_REFERENCE, oldNumberOfGridInReference, numberOfGridInReference));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public long getUniversallyUniqueIdentifierOffset() {
		return universallyUniqueIdentifierOffset;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setUniversallyUniqueIdentifierOffset(long newUniversallyUniqueIdentifierOffset) {
		long oldUniversallyUniqueIdentifierOffset = universallyUniqueIdentifierOffset;
		universallyUniqueIdentifierOffset = newUniversallyUniqueIdentifierOffset;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GridsPackage.GRID_DEFINITION_TEMPLATE3101__UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET, oldUniversallyUniqueIdentifierOffset, universallyUniqueIdentifierOffset));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__SHAPE_OF_THE_EARTH:
				return getShapeOfTheEarth();
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_USED:
				return getNumberOfGridUsed();
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_IN_REFERENCE:
				return getNumberOfGridInReference();
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET:
				return getUniversallyUniqueIdentifierOffset();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__SHAPE_OF_THE_EARTH:
				setShapeOfTheEarth((Byte)newValue);
				return;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_USED:
				setNumberOfGridUsed((Integer)newValue);
				return;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_IN_REFERENCE:
				setNumberOfGridInReference((Byte)newValue);
				return;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET:
				setUniversallyUniqueIdentifierOffset((Long)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__SHAPE_OF_THE_EARTH:
				setShapeOfTheEarth(SHAPE_OF_THE_EARTH_EDEFAULT);
				return;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_USED:
				setNumberOfGridUsed(NUMBER_OF_GRID_USED_EDEFAULT);
				return;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_IN_REFERENCE:
				setNumberOfGridInReference(NUMBER_OF_GRID_IN_REFERENCE_EDEFAULT);
				return;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET:
				setUniversallyUniqueIdentifierOffset(UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__SHAPE_OF_THE_EARTH:
				return shapeOfTheEarth != SHAPE_OF_THE_EARTH_EDEFAULT;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_USED:
				return numberOfGridUsed != NUMBER_OF_GRID_USED_EDEFAULT;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__NUMBER_OF_GRID_IN_REFERENCE:
				return numberOfGridInReference != NUMBER_OF_GRID_IN_REFERENCE_EDEFAULT;
			case GridsPackage.GRID_DEFINITION_TEMPLATE3101__UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET:
				return universallyUniqueIdentifierOffset != UNIVERSALLY_UNIQUE_IDENTIFIER_OFFSET_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (shapeOfTheEarth: "); //$NON-NLS-1$
		result.append(shapeOfTheEarth);
		result.append(", numberOfGridUsed: "); //$NON-NLS-1$
		result.append(numberOfGridUsed);
		result.append(", numberOfGridInReference: "); //$NON-NLS-1$
		result.append(numberOfGridInReference);
		result.append(", universallyUniqueIdentifierOffset: "); //$NON-NLS-1$
		result.append(universallyUniqueIdentifierOffset);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.grids.IGridDefinition#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		shapeOfTheEarth = buffer.get();
		numberOfGridUsed = buffer.getInt();
		numberOfGridInReference = buffer.get();
		universallyUniqueIdentifierOffset = buffer.position();
	}

} //GridDefinitionTemplate3101Impl
